<html>
<head>
    <title>000 | Hello Cube | J3D</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable = no">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <link rel="stylesheet" href="common/common.css"/>
    
</head>
<body>

    <script type="text/javascript" src="../build/j3d.js"></script>
    
    <script id="demo-source">
    
    var cube, engine;
    
    var setup = function() {
        engine = new J3D.Engine();
        engine.setClearColor(J3D.Color.black);
    
        var ambient = new J3D.Transform();
        ambient.light = new J3D.Light(J3D.AMBIENT);
        ambient.light.color = new J3D.Color(0.5, 0.5, 0.5, 1);
    
        var light = new J3D.Transform();
        light.light = new J3D.Light(J3D.DIRECT);
        light.light.color = new J3D.Color(0.5, 0.5, 0.5, 1);
        light.rotation = new v3(-Math.PI, 0, Math.PI);
    
        var camera = new J3D.Transform();
        camera.camera = new J3D.Camera();
        camera.position.z = 4;

        cube = new J3D.Transform('cube');
        cube.geometry = J3D.Primitive.Cube(1, 1, 1);
        cube.renderer = J3D.BuiltinShaders.fetch("Normal2Color");
    
        engine.scene.setCamera(camera);
        engine.scene.add(camera, cube, light, ambient);
    }
    
    var render = function() {
        requestAnimationFrame(render);
        cube.rotation.x += Math.PI * J3D.Time.deltaTime / 6000;
        cube.rotation.y += Math.PI / 2 * J3D.Time.deltaTime / 3000;
        engine.render();
    }

    setup();
    render();
    
    </script>
</body>
</html> 












